package com.yneusoft.manage.config;

import com.yneusoft.dao.entity.UserState;
import com.yneusoft.dao.mapper.UserStateMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.List;

/**
 * @author lt
 * @date 2021/10/25 19:50
 * @description: 将UserState放入缓存  数据Map初始化
 */
@Component
public class CacheInitiation {
    @Autowired
    private UserStateMapper userStateMapper;

    @PostConstruct
    public void initMap(){
        List<UserState> list = userStateMapper.selectList(null);
        UserState.dataList = list;
        for(int i=0;i<list.size();i++){
            UserState.dataMap.put(i,list.get(i));
        }
        System.out.println("<----数据map加载完毕---->");
    }
}
